var page = {
	data: function() {
		return {
			totalPage: '', //列表数据总页数
			pageArr: [], //分页数组
			currentPage: 1, //当前页数
			currentPages: '', //输入框的页数
			onePageCount: 4, //每页的数量
		}
	},
	methods: {
		//分页器

		//		初始化页码
		initPage: function() {
			var _this = this;
			for(var i = 1; i <= 5; i++) {
				if(i <= this.totalPage) {
					this.pageArr.push(i);
				}
			}
		},
		//左一个点击
		leftClick: function() {
			if(this.currentPage > 1) {
				this.currentPage--;
				if(this.currentPage < this.pageArr[0]) {
					this.pageArr.pop();
					this.pageArr.unshift(this.currentPage);
				}
				this.getNewsList(this.currentPage);
			}
		},
		//右一个点击
		rightClick: function() {
			if(this.currentPage < this.totalPage) {
				this.currentPage++;
				if(this.currentPage > this.pageArr[this.pageArr.length - 1]) {
					this.pageArr.shift();
					this.pageArr.push(this.currentPage);
				}
				this.getNewsList(this.currentPage);
			}
		},
		//最左点击
		maxLeftClick: function() {
			this.pageArr = [];
			this.currentPage = 1;
			for(var i = 1; i <= 5; i++) {
				if(i <= this.totalPage) {
					this.pageArr.push(i);
				}
			}
			this.getNewsList(this.currentPage);
		},
		//最右点击
		maxRightClick: function() {
			this.pageArr = [];
			this.currentPage = this.totalPage;
			var start = this.totalPage - 4;
			for(var i = start; i <= this.totalPage; i++) {
				if(i > 0) {
					this.pageArr.push(i);
				}
			}
			this.getNewsList(this.currentPage);
		},
		//点击页面的页数
		clickTarget: function(id) {
			this.currentPage = id;
			this.getNewsList(this.currentPage);
		},
		//点击跳转到指定的页数
		goPage: function() {
			//			console.log('currentPage'+this.currentPage)
			//			console.log('totalPage'+this.totalPage)
			//			this.pageArr = [];
			//			var start = parseInt(this.currentPage);
			//			for(var i = start;i<=start+5;i++){
			//				if(i<=this.totalPage){
			//					this.pageArr.push(i);
			//				}
			//			}
			//			var arr = [];
			//			var cstart = this.pageArr[0];
			//			for(var j = 0;j<5-this.pageArr.length;j++){
			//				arr.push(cstart)
			//				this.pageArr.unshift(cstart-j);
			//				console.log(this.pageArr[0])
			//			}
			this.currentPage = this.currentPages;
			if(this.currentPage <= this.totalPage) {
				this.getNewsList(this.currentPages);
			} else {
				xq.toast1('最大页数是：' + this.totalPage);
			}
		},
	}
}